import $ from "jquery";
import {url} from "../../util/config";
import {message} from "antd";
import login from "../login";
function getNewLogin(key) {
    return getUserBindContent(key)
}
export default function getUserBindContent(key) {
    console.log(key)
    let usersBindContent = null;
    let token = localStorage.getItem("token")
    $.ajax({
        async:false,
        headers: {
            'Accept': "application/json",
                'Authorization': token
        },
        url: url.api_url+`BindRole/GetUserBindContent`,
        type: 'POST',
         contentType:"application/json",
         data:JSON.stringify({
             USER_WORK_NUM:key
         }),
        success: function (result) {
            if(result.result=="Token過期請重新登錄"){
                login(localStorage.getItem("account"), localStorage.getItem("password"));
                usersBindContent = getNewLogin(key);
            }else {
                usersBindContent = {
                    bindRoleIdList:result.result
                }
            }
        },
        error:function (error) {
            message.error("请求异常")
        }
    })
    return usersBindContent;

    // return(
    //     {
    //         bindRoleIdList:[1,2,3,4,5],
    //     }
    // )
}
